﻿package com.snzflash.components.section 
{
	import com.snzflash.components.ComponentBase;
	import com.snzflash.events.ComponentEvent;
	import gs.TweenLite;
	
	/**
	 * Базовый класс для секций
	 * @author firsoff maxim, tel: +79222345364, skype: maxim.firsoff
	 */
	public class SectionBase extends ComponentBase
	{
		
		// PROPERTIES
	
		// public
		
		// private
		private var _openDuration:Number;
		private var _closeDuration:Number;
		// == STATIC==
		
		public static const DEFAULT_OPEN_DURATION:Number = 0.4;
		public static const DEFAULT_CLOSE_DURATION:Number = 0.4;
		// CONSTRUCTOR
		public function SectionBase() 
		{
			super();
		};
		
		// METHODS
	
		// public
		
		public function reset():void 
		{
			
		}
		
		public function close(immediate:Boolean = false):void 
		{
			TweenLite.to ( this, _closeDuration, { alpha : 0 } );
		};
		
		
		public function open(immediate:Boolean = false):void 
		{
			TweenLite.to ( this, _openDuration, { alpha : 1 } );
		};
		
		override public function destroy():void 
		{
			//super.destroy();
			dispatchEvent(new ComponentEvent(ComponentEvent.DESTROY));
			removeStageDetector();
			closeAndDestroy();
		};
		// private
		protected function closeAndDestroy():void 
		{
			TweenLite.to ( this, _closeDuration, { alpha : 0, onComplete:onDestroy } );
		}
		
		protected function onDestroy():void
		{
			destroyContent();
		};
		
		
		override protected function initProperties():void 
		{
			super.initProperties();
			_openDuration = DEFAULT_OPEN_DURATION;
			_closeDuration = DEFAULT_CLOSE_DURATION;
		};
		
		
		// getters/setters
		
		// == STATIC==
		
		
		// HANDLERS
	};

};